import { createRouter, createWebHistory, createWebHashHistory } from "vue-router";
import Index from "../views/Index/Index.vue";
import Home from "../views/Index/Home.vue";
import Login from "../views/Login.vue";
import Userinfo from "../views/Index/Userinfo.vue";
import MenuList from "../views/Bew/MenuList.vue";
import RoleList from "../views/Bewadmin/RoleList.vue";
import DepList from "../views/Bewadmin/DepList.vue";
import UserList from "../views/Bewadmin/UserList.vue";
import TestList from "../views/BewTest/TestList.vue";

// 商城管理
import GoodsList from "../views/Shop/GoodsList.vue";
import GoodsType from "../views/Shop/GoodsType.vue";

// 订单管理
import OrderList from "../views/Shop/OrderList.vue";

const routes = [
  {
    path: "/",
    alias: "/login",
    name: "Login",
    component: Login,
    meta: {
      title: "phpAdmin - 登录",
    },
  },
  {
    path: "/index",
    name: "Index",
    component: Index,
    meta: {
      title: "phpAdmin - 首页",
    },
    children: [
      {
        path: "home",
        name: "Home",
        component: Home,
        meta: {
          title: "phpAdmin - 首页",
        },
      },
      {
        path: "userinfo",
        name: "Userinfo",
        component: Userinfo,
        meta: {
          title: "phpAdmin - 个人中心",
        },
      },
      {
        path: "menulist",
        name: "MenuList",
        component: MenuList,
        meta: {
          title: "phpAdmin - 导航管理",
        },
      },
      {
        path: "rolelist",
        name: "RoleList",
        component: RoleList,
        meta: {
          title: "phpAdmin - 角色管理",
        },
      },
      {
        path: "deplist",
        name: "DepList",
        component: DepList,
        meta: {
          title: "phpAdmin - 部门管理",
        },
      },
      {
        path: "userlist",
        name: "UserList",
        component: UserList,
        meta: {
          title: "phpAdmin - 管理员管理",
        },
      },
      {
        path: "testlist",
        name: "TestList",
        component: TestList,
        meta: {
          title: "phpAdmin - 演示",
        },
      },
      {
        path: "GoodsList",
        name: "GoodsList",
        component: GoodsList,
        meta: {
          title: "phpAdmin - 商品列表",
        },
      },
      {
        path: "goodsType",
        name: "GoodsType",
        component: GoodsType,
        meta: {
          title: "phpAdmin - 商品分类",
        },
      },
      {
        path: "orderList",
        name: "OrderList",
        component: OrderList,
        meta: {
          title: "phpAdmin - 订单查询",
        },
      },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL),
  routes,
});

router.beforeEach((to, from) => {
  document.title = to.meta.title;
});

export default router;
